package net.rlair.sbdemo.dao.mybatis.bootmapper;

import net.rlair.sbdemo.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * MyBatisDao.
 *
 * @author ybr
 * @version 1.0.0.0
 */
@Repository
public interface YangbairongMyBatisUserDao {

	@Select("SELECT * FROM t_user limit #{page.offset}, #{page.pageSize}")
	List<User> findUsersByPage(@Param("page") Pageable page);

	@Select("SELECT COUNT(1) FROM t_user")
	int countUser();

	@Insert("insert into t_user values (#{user.id}, #{user.name}, #{user.password}, #{user.sex}, #{user.created}, #{user.updated})")
	int insertUser(@Param("user") User user);

}